<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>课工场题库</title>
</head>
<%@include file="../common/include-header.jsp"%>
<%@include file="../common/include-footer.jsp" %>
<link href="/static/css/history.css" rel="stylesheet"/>
<base href="${pageContext.request.contextPath}/">
<body>

<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table" data-mobile-responsive="true">

    </table>
</div>
<script th:inline="javascript">
    var prefix = "score";
    $(function () {
        var options = {
            url: prefix + "/list?stuNo="+${user.id},
            sortName: "asc",
            height: 500,
            modalName: "历史",
            columns: [
                {
                    field: 'id',
                    title: '序号'
                },
                {
                    field: 'title',
                    title: '考试名称'
                },
                {
                    field: 'correctAmount',
                    title: '答对量'
                },
                {
                    field: 'okAmount',
                    title: '答题量'
                },
                {
                    field: 'amount',
                    title: '总题量'
                },
                {
                    field: 'score',
                    title: '得分'
                },
                {
                    field: 'examTime',
                    title: '考试时间',
                    formatter:function(val, item, rowIndex){
                        var date = new Date(val);
                        var YY = date.getFullYear() + '-';
                        var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                        var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
                        var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
                        var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
                        var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
                        return YY + MM + DD +" "+hh + mm + ss;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        //actions.push('<a class="btn btn-s uccess btn-xs ' + '" onclick="">再做一次</a> ');
                        //actions.push('<a class="btn btn-success btn-xs ' + '" onclick="">查看报告</a> ');
                        actions.push('<a  class="btn btn-success btn-xs ' + '" onclick="findById(this)">试题分析</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        //科目下拉款初始化
        $.ajax({
            url:"${pageContext.request.contextPath}/course/findAll",    //请求的url地址
            dataType:"json",   //返回格式为json
            async:true,//请求是否异步，默认为异步，这也是ajax重要特性
            type:"POST",   //请求方式
            success:function(result){
                var list = result.data;
                for(var i=0;i<list.length;i++){
                    var courseId = list[i].id;
                    var courseName =list[i].name;
                    //给下拉框动态赋值
                    $("#courseId").append("<option value='"+courseId+"'>"+courseName+"</option>");
                }
            }
        });

    });

    function findById(zs) {
        var id = $(zs).parents("tr").children().eq(0).text();
        location.href = '${pageContext.request.contextPath}/examDetail/findById?id='+id;
    }
</script>
</body>
</html>
